package com.smartcommunity.job;

import com.smartcommunity.entity.waterEleGasUsage.VillageWaterEleGasUsage;
import com.smartcommunity.service.waterEleGasUsage.VillageWaterEleGasUsageService;
import com.smartcommunity.service.waterEleGasUsage.WaterEleGasUsageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author nieming
 * @descrition 小区水电气使用情况统计
 * @date 2020/5/15
 */
@Component
@Slf4j
public class VillageWaterEleGasStatisticJob {
    @Autowired
    private VillageWaterEleGasUsageService villageWaterEleGasUsageService;
    @Autowired
    private WaterEleGasUsageService waterEleGasUsageService;

//    @Scheduled(initialDelay = 1000 * 10, fixedDelay = 1000 * 60 * 60)
    public void start() {
        List<VillageWaterEleGasUsage> villageWaterEleGasUsages = waterEleGasUsageService.statisticVillageUsage();
        if (!CollectionUtils.isEmpty(villageWaterEleGasUsages)) {
            villageWaterEleGasUsageService.saveOrUpdate(villageWaterEleGasUsages);
        }
    }
}
